/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.accounting;

import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import src.domain.gl.FstmtReport;

/**
 *
 * @author Lalugina
 */
public class RptFstmtDS implements JRDataSource{
    private int index = -1;
    private List<FstmtReport> fstmtReports;

    public RptFstmtDS(List<FstmtReport> fstmtReports) {
        super();
        this.fstmtReports = fstmtReports;
    }

    @Override
    public boolean next() throws JRException {
        index++;
        return (index < fstmtReports.size());
    }

    @Override
    public Object getFieldValue(JRField jrf) throws JRException {
        Object value = null;
	String fieldName = jrf.getName();
        switch (fieldName) {
            case "lineType": value = fstmtReports.get(index).getLineType(); break;
            case "lineDescription": value = fstmtReports.get(index).getLineDescription(); break;
            case "value01": value = fstmtReports.get(index).getValue01(); break;
            case "value02": value = fstmtReports.get(index).getValue02(); break;
            case "value03": value = fstmtReports.get(index).getValue03(); break;
            case "value04": value = fstmtReports.get(index).getValue04(); break;
        }
	return value;
    }
    
}
